package org.txlcn.demo.serviceb;

import com.codingapi.txlcn.tc.annotation.LcnTransaction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.txlcn.demo.common.entity.Account;

/**
 * Description:
 * Date: 2018/12/25
 *
 * @author ujued
 */
@Service
@Slf4j
public class AccountServiceImpl {
    @Autowired
    private  AccountMapper accountMapper;


    @LcnTransaction
    @Transactional(rollbackFor = Exception.class)
    public String rpc(Integer money) {
        Account oldAccount = accountMapper.selectById("1");
        oldAccount.setMoney(oldAccount.getMoney() - money);
        accountMapper.updateById(oldAccount);
//        int i = 1/0;
        return "ok-service-b";
    }
}
